<template>
  <view id="app">
	  <u-tabs :list="list" :is-scroll="true" :current="current" @change="change"></u-tabs>
    <ALineOfaColumn :ALineOfaColumn='listData' @ALineOfaColumnFunc='theCurrent'></ALineOfaColumn>

    <loading v-if="listData.length === 0"></loading>
  </view>
</template>

<script>
import { toplist } from "../../../../../utlis/bilibili.js";
export default {
  data() {
    return {
      dataimgArrl: [],
	  list:toplist,
      listData: [],
      pageObj: {
        page: 1,
      },
	  current: 0,
      keyid: "",
    };
  },
  onLoad() {
   this.getlistConditio(0);
  },
  onPullDownRefresh() {
    this.pageObj.page = 1;
    this.getlistConditio(this.keyid);
  },
  onReachBottom() {
    const { count, num, size } = this.pageObj;
    this.pageObj.page++;
    if (count !== num) {
      this.getlistConditio(this.keyid);
    }
  },
  methods: {
    async getlistConditio(rid) {
      let data = await this.http(this.api.ranKingList, {
		// day
        rid,
      },'GET');

      this.pageObj = Object.assign(this.pageObj, data.page);
       //#ifdef H5
      data.list.forEach(async (item) => {
        item.pic =
          this.baseHttpUrl +
          (await this.http(
            this.api.bilibili_get_img,
            { url: item.pic },
            "GET"
          ));
      });
      //#endif
      uni.stopPullDownRefresh();
      this.listData = [...this.listData, ...data.list];
    },
    theCurrent(data) {
      uni.navigateTo({
        url: `./info?data=${JSON.stringify(data)}`,
      });
    },
	change(index) {
		index = index+1;
		this.listData=[];
		this.keyid = this.list[index].key;
		this.getlistConditio(this.keyid);
		this.current = index;
	},
  },
};
</script>

<style scoped lang="less">
.wrap {
  padding: 10rpx;
}
</style>
